<?php
	
	class DetailsController extends CommonController{
		
		private $model;
		public function __init(){
			parent::__init();
			$this->model = K('article');
		}
		
		
		/**
		 * 内容显示的控制器
		 */
		 public function details(){
		 	$this->assign('title',C('WEBNAME'));
			$this->assign('copy',C('copy'));
		 	//获得拿到文章的ID
		 	$aid = Q('get.aid',0,'intval');
			//查询相应aid的文章
			$artInfo = $this->model->findArtInfo($aid);
			//给浏览数+1
			$this->model->inc('click',"aid={$aid}",1);
			
			
			
			$comment = K('comment')->join('__user__ u JOIN __comment__ c ON u.uid=c.user_uid')->where("article_aid={$aid}")->order('addtime DESC')->all();
			//回复 
			$this->assign('comment',$comment);
			//文章详细内容
			$this->assign('artInfo',$artInfo);
		 	$this->dis('details');
		 }
		/**
		 * 发表评论的方法
		 */
		 
		 public function comment(){
		 	Q('post.user_uid',session('uid'));
			$comment = K('comment');
		 	if($comment->addComment()){
		 		$this->success('评论成功');
		 	}else{
		 		$this->error($comment->error);
		 	}
		 }
		 
		 
		 /**
		  * 面包
		  */
		
		
		
	}
